class Tree(object):
    def __init__(self, value=0, left=None, right=None):
        self.value = value
        self.left = left
        self.right = right
    
    def show(self):
        print(self.value)
 
# 前序
def preOrder(node):
    if node.value:
        node.show()
        if node.left:
            preOrder(node.left)
        if node.right:
            preOrder(node.right)
 
# 中序
def midOrder(node):
    if node.value:
        if node.left:
            midOrder(node.left)
        node.show()
        if node.right:
            midOrder(node.right)
 
# 后序
def botOrder(node):
    if node.value:
        if node.left:
            botOrder(node.left)
        if node.right:
            botOrder(node.right)
        node.show()
 
if __name__ == '__main__':
 
    left = Tree("L")
    right = Tree("R")
    root = Tree("root", left, right)

    preOrder(root)
    midOrder(root)
    botOrder(root)

2